import CryptoJS from 'crypto-js'

const key = '5JKRGV0QO4WK1WCWVK55YEU0A1NPOXOP';

// 加密函数
export function encrypt(data) {
  const secretKey = CryptoJS.enc.Utf8.parse(key);
  const srcs = CryptoJS.enc.Utf8.parse(data);
  const encrypted = CryptoJS.AES.encrypt(srcs, secretKey, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  return encrypted.toString();
}

// 解密函数
export function decrypt(data) {
  const secretKey = CryptoJS.enc.Utf8.parse(key);
  const decrypt = CryptoJS.AES.decrypt(data, secretKey, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  return CryptoJS.enc.Utf8.stringify(decrypt).toString();
}
